
Page({

  /**
   * 页面的初始数据
   */
  data: {
    schema:[],
    formData:{
     
    },
    title: '',
    result: '',
    remark: '',
    webUrl: '',
    apiName: '',
    showPrivacy: false
  },
  onUnload() {
    wx.offBeforePageUnload();
    wx.offBeforePageLoad();
    wx.offBeforeAppRoute();
    wx.offAppRouteDone();
    wx.offAppRoute();
    wx.offAfterPageUnload();
    wx.offAfterPageLoad();
  },
  onLoad(options) {
    const that = this;
    console.log('options', options)
    wx.setNavigationBarTitle({
      title: options.title,
    })
    
    this.setData({
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    if(options.zh === 'wx.onBeforePageUnload' || options.zh === 'wx.offBeforePageUnload') {
      wx.onBeforePageUnload(res => {
        that.setData({
          result: res,
          apiName: options.zh
        })
      })
    }
    if(options.zh === 'wx.onBeforePageLoad' || options.zh === 'wx.offBeforePageLoad') {
      wx.onBeforePageLoad(res => {
        that.setData({
          result: res,
          apiName: options.zh
        })
      })
    }
    if(options.zh === 'wx.onBeforeAppRoute' || options.zh === 'wx.offBeforeAppRoute') {
      wx.onBeforeAppRoute(res => {
        that.setData({
          result: res,
          apiName: options.zh
        })
      })
    }
  },
  getFormData(e) {
    console.log('formdata==', e.detail.formData);
    this.setData({
      formData: e.detail.formData
    })
  },
  approuteNext(e) {
    wx.navigateTo({
      url: `/packageAPI/pages/approute/approuteNext/approuteNext?zh=${this.data.zh}`
    })
  },
  onAppRouteDone(e) {
    wx.onAppRouteDone(res => {
      this.setData({
        result: res,
        apiName: e.currentTarget.dataset.apiname
      })
    })
  },
  onAppRoute(e) {
    wx.onAppRoute(res => {
      this.setData({
        result: res,
        apiName: e.currentTarget.dataset.apiname
      })
    })
  },
  onAfterPageUnload(e) {
    wx.onAfterPageUnload(res => {
      this.setData({
        result: res,
        apiName: e.currentTarget.dataset.apiname
      })
    })
  },
  onAfterPageLoad(e) {
    wx.onAfterPageLoad(res => {
      this.setData({
        result: res,
        apiName: e.currentTarget.dataset.apiname
      })
    })
  },
  offBeforePageUnload() {
    wx.offBeforePageUnload()
    this.setData({
      result: '清空返回数据'
    })
  },
  offBeforePageLoad() {
    wx.offBeforePageLoad()
    this.setData({
      result: '清空返回数据'
    })
  },
  offBeforeAppRoute() {
    wx.offBeforeAppRoute()
    this.setData({
      result: '清空返回数据'
    })
  },
  offAppRouteDone() {
    wx.offAppRouteDone()
    this.setData({
      result: '清空返回数据'
    })
  },
  offAppRoute() {
    wx.offAppRoute()
    this.setData({
      result: '清空返回数据'
    })
  },
  offAfterPageUnload() {
    wx.offAfterPageUnload()
    this.setData({
      result: '清空返回数据'
    })
  },
  offAfterPageLoad() {
    wx.offAfterPageLoad()
    this.setData({
      result: '清空返回数据'
    })
  }
})